<?php

namespace App\Log\Service;

use App\Models\Applogs;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Str;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;

class ApplogsViewerService 
{
    public function __construct(Applogs $model)
    {
        $this->model = $model;
       
    }
    public function getList($request,$data=[])
    {

        $type=$data['type'];
        $level=$data['level'];
        if($level=='all'){
            $sql="SELECT * FROM `app_logs`  where type='{$type}'    order by id desc";
        }else{
            $sql="SELECT * FROM `app_logs`  where type='{$type}' and level='{$level}'   order by id desc";
        }
        
        $list=DB::select($sql);
        $list = array_map('get_object_vars', $list);
        return $list;
       
    }

}
